package com.albon.soccer;

import com.albon.util.Logg;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;

public class DatabaseHelper extends SQLiteOpenHelper {

	private final String TAG = "DatabaseHelper";
	public static final String DATABASE_NAME = "soccer.db";
	public static final String DATABASE_TABLE_NAME = "SOCCER";
	private static final int DTATBASE_VERSION = 1;
	private Context mContext;
	private String dbName = null;
	private SQLiteDatabase database;
	
	
	public static final String DATABASE_COLUMN_ID = "_id"; // key값
	public static final String DATABASE_COLUMN_ENABLED = "enabled"; //알람 on/off
	public static final String DATABASE_COLUMN_REAL_DATE = "real_date"; // 실제 경기일정날짜
	public static final String DATABASE_COLUMN_REAL_TIME = "real_time"; // 실제 경기 일정 시간 
	public static final String DATABASE_COLUMN_COMPARE_DATE = "compare_date"; // 날짜비교
	public static final String DATABASE_COLUMN_SETTING_YEAR = "setting_year"; // 사용자가 설정한 년
	public static final String DATABASE_COLUMN_SETTING_MONTH = "setting_month"; // 사용자가 설정한 월
	public static final String DATABASE_COLUMN_REAGUE = "reague"; // 리그
	public static final String DATABASE_COLUMN_STADIUM = "stadium"; // 구장
	public static final String DATABASE_COLUMN_A_TEAM = "a_team"; //a 팀
	public static final String DATABASE_COLUMN_B_TEAM = "b_team"; //b 팀
	public static final String DATABASE_COLUMN_SCORE = "score"; // 스코어
	public static final String DATABASE_COLUMN_ALARM_TITLE = "alarm_title"; // 알람 타이틀
	public static final String DATABASE_COLUMN_ALARM_RINGTONE = "alarm_ringtone"; // 알람 링톤 url
	public static final String DATABASE_COLUMN_ALARM_VOLUME = "alarm_volume"; // 알람 볼륨
	public static final String DATABASE_COLUMN_ALARM_VIBRATE = "alarm_vibrate"; // 알람 진동 on/off
	public static final String DATABASE_COLUMN_ALARM_AUTO_OFF_TIME = "alarm_auto_off_time"; // 알람 자동 종료 시간
	public static final String DATABASE_COLUMN_SMS = "sms"; // 문자중계
	public static final String DATABASE_COLUMN_VIDEO = "video"; // 동영상중계
	public static final String DATABASE_COLUMN_RECORD = "record"; // 알람 자동 종료 시간
	public static final String DATABASE_COLUMN_HIGHLIGHT = "highlight"; // 알람 자동 종료 시간
	public static final String DATABASE_COLUMN_POWER = "power"; // 알람 자동 종료 시간
	public static final String DATABASE_COLUMN_NOTIFICATION = "notification"; // 알림
	public static final String DATABASE_COLUMN_EXPLANATION = "explanation"; // 알림
	
	
	public DatabaseHelper(Context context, String name) {
		super(context, name, null, DTATBASE_VERSION);
		// TODO Auto-generated constructor stub
		 mContext = context;
		 dbName = name;
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		// TODO Auto-generated method stub
		database = db;
		if(dbName.equals(DATABASE_NAME)){
			Logg.e(TAG, "DatabaseHelper-DATABASE_NAME");
			db.execSQL("CREATE TABLE " + DATABASE_TABLE_NAME + " ("
					+ DATABASE_COLUMN_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " 
					+ DATABASE_COLUMN_ENABLED + " TEXT , " 
					+ DATABASE_COLUMN_REAL_DATE + " TEXT , " 
					+ DATABASE_COLUMN_REAL_TIME + " TEXT , " 
					+ DATABASE_COLUMN_COMPARE_DATE + " TEXT , " 
					+ DATABASE_COLUMN_SETTING_YEAR + " TEXT , " 
					+ DATABASE_COLUMN_SETTING_MONTH + " TEXT , " 
					+ DATABASE_COLUMN_REAGUE + " TEXT , " 
					+ DATABASE_COLUMN_STADIUM + " TEXT , " 
					+ DATABASE_COLUMN_A_TEAM + " TEXT , " 
					+ DATABASE_COLUMN_B_TEAM + " TEXT , " 
					+ DATABASE_COLUMN_SCORE + " TEXT , " 
					+ DATABASE_COLUMN_ALARM_TITLE + " TEXT , " 
					+ DATABASE_COLUMN_ALARM_RINGTONE + " TEXT , " 
					+ DATABASE_COLUMN_ALARM_VOLUME + " TEXT , " 
					+ DATABASE_COLUMN_ALARM_VIBRATE + " TEXT , " 
					+ DATABASE_COLUMN_ALARM_AUTO_OFF_TIME + " TEXT , " 
					+ DATABASE_COLUMN_SMS + " TEXT , " 
					+ DATABASE_COLUMN_VIDEO + " TEXT , " 
					+ DATABASE_COLUMN_RECORD + " TEXT , " 
					+ DATABASE_COLUMN_HIGHLIGHT + " TEXT , " 					
					+ DATABASE_COLUMN_POWER + " TEXT , " 					
					+ DATABASE_COLUMN_NOTIFICATION + " TEXT , " 					
					+ DATABASE_COLUMN_EXPLANATION + " TEXT );"); 
		}
	}

	@Override
	public void onUpgrade(SQLiteDatabase arg0, int arg1, int arg2) {
		// TODO Auto-generated method stub

	}

}
